<?php
class CommentAction extends BaseAction{
	
	  
    public function commentList(){
    	$type = 'News';
    	if($_GET['type']){
    		$type = $_GET['type'];
    	}
    	$comment= M('Comment');
    	import("ORG.Util.Page"); // 导入分页类   
      $count = $comment->where('type="'.$type.'"')->count(); // 查询满足要求的总记录数   
      $Page  = new Page($count,10); // 实例化分页类 传入总记录数和每页显示的记录数   
      $show  = $Page->show(); // 分页显示输出   
      $list  = $comment->where('type="'.$type.'"')->limit($Page->firstRow.','.$Page->listRows)->select();   
      $this->assign('list',$list); // 赋值数据集   
      $this->assign('page',$show); // 赋值分页输出
      $this->assign('type',$type);
      $this->assign('models',D('Model')->getModel());   
    	$this->display();
    }
    
    //审核多条记录
   public function doAudit()
	 {
			//删除指定记录
			$model = M('Comment');
			if(!empty($model)) {
				$id = $_REQUEST['id'];
				if(isset($id)) {
					if($model->where('id In('.$id.')')->setField('status',1)){
						$this->assign("jumpUrl", __URL__.'/commentList');
						$this->success('操作成功！');
					}else {
						$this->error("操作失败!");
					}
				}else {
					$this->error('非法操作');
				}
			}
	 }

    //删除多条记录
   public function delete()
	 {
			//删除指定记录
			$model = M('Comment');
			if(!empty($model)) {
				$id = $_REQUEST['id'];
				if(isset($id)) {
					if($model->where('id In('.$id.')')->delete()){
						$this->assign("jumpUrl", __URL__.'/commentList');
						$this->success('删除成功！');
						

					}else {
						$this->error("删除失败!");
					}
				}else {
					$this->error('非法操作');
				}
				$this->forward();
			}
	 }
   public function del(){
   	  $adObj = M('Comment');
   	  $ad = $adObj->find($_GET['id']);
   	  if($ad){
   	  		$adx = $adObj->where('id='.$_GET['id'])->delete();
   	  }else{
   	  	
   	  	$this->error('您要删除的对象不存在！');
   	  }
   		
   		if($adx){
   			$this->success('删除成功！');
   		}else{
   			$this->error('删除失败！');
   		}
   }
   
    
 
}
?>